hysop.operator.memory_reordering module

@file memory_reordering.py Memory ordering related operators.

class hysop.operator.memory_reordering.MemoryReordering(fields, variables, target_memory_order, output_fields=None, implementation=None, name=None, base_kwds=None, **kwds)[source]

Bases: ComputationalGraphNodeGenerator

Operator generator for inplace and out of place field memory reordering.

Available implementations are:

*python (numpy based memory reordering, n-dimensional)

This is currently used to convert C_CONTIGUOUS fields to F_CONTIGUOUS fields.

Implementations handle only one field at a time but this graph node generator generates an operator per supplied field, possibly on different implementation backends.

See hysop.operator.base.reorder.MemoryReorderingBase for operator backend implementation interface.

Initialize a MemoryReordering operator generator operating on CartesianTopology topologies. MemoryReordering is deduced from topology requirements.

Parameters:
  • fields (Field, list or tuple of Fields) – Input continuous fields to be memory reordered, at least 2D. All fields should have the same dimension.

  • output_fields (Field, list or tuple of Fields, optional) – Output continuous fields where the results are stored. Reordered shapes should match the input shapes. By default output_fields are the same as input_fields resulting in inplace memory reordering. Input and output are matched by order int list/tuple.

  • variables (dict) – Dictionary of fields as keys and CartesianTopologyDescriptors as values.

  • target_memory_order (MemoryOrdering) – Target memory order to achieve.

  • implementation (Implementation, optional, defaults to None) –

    target implementation, should be contained in available_implementations(). If implementation is set and topology does not match backend,

    RuntimeError will be raised on _generate.

    If None, implementation will be set according to topologies backend, different implementations may be choosen for different Fields if defined on different backends.

  • name (string) – prefix for generated operator names

  • base_kwds (dict, optional, defaults to None) – Base class keywords arguments. If None, an empty dict will be passed.

  • kwds – Keywords arguments that will be passed towards implementation memory reordering operator __init__.

Notes

Out of place reordering will always be faster to process. In place reordering requires an extra buffer and an extra copy.

  • About dimensions:
    • No limit.

A MemoryReordering operator implementation should support the MemoryReorderingBase interface (see hysop.operator.base.memory_ordering.MemoryOrdering).

This ComputationalGraphNodeFrontend will generate a operator for each input and output ScalarField pair.

All implementations should raise MemoryReorderingNotImplementedError if the user supplied parameters leads to unimplemented or unsupported memory reordering features.

classmethod default_implementation()[source]
classmethod implementations()[source]
exception hysop.operator.memory_reordering.MemoryReorderingNotImplementedError[source]

Bases: NotImplementedError

Error raised for unimplemented memory reordering operator configurations.